package com.spider.spiderorderbasedata.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spider.spiderorderbasedata.mapper.RequestClassMapper;
import com.spider.spiderorderbasedata.model.entity.RequestClass;
import com.spider.spiderorderbasedata.service.RequestClassService;
import org.springframework.stereotype.Service;

/**
 * @author xiong.bo
 * @version 1.0
 * @date 2024/5/10 8:20 下午
 */

@Service
public class RequestClassServiceImpl extends ServiceImpl<RequestClassMapper, RequestClass>
        implements RequestClassService {

    @Override
    public IPage<RequestClass> selectPage(int page, int pageSize) {
        Page<RequestClass> pageObject = new Page(page, pageSize);
        LambdaQueryWrapper<RequestClass> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(RequestClass::getCreateTime);
        return this.baseMapper.selectPage(pageObject, queryWrapper);
    }

    @Override
    public RequestClass findById(Long id) {
        return getById(id);
    }

    @Override
    public RequestClass saveRequestClass(RequestClass requestClass) {
        this.save(requestClass);
        return requestClass;
    }

    @Override
    public RequestClass editRequestClass(RequestClass requestClass) {
        this.updateById(requestClass);
        return requestClass;
    }

    @Override
    public Boolean deleteRequestClass(Long id) {
        return removeById(id);
    }
}
